package main

import (
	"bufio"
	"fmt"
	"net"
	"os"
)

func main() {
	conn, err := net.Dial("tcp", "10.251.50.46:8888")
	if err != nil {
		fmt.Println("client dial err=", err)
		return
	}
	reader := bufio.NewReader(os.Stdin)
	for {
		line, err := reader.ReadString('\n')
		if err != nil {
			fmt.Println("ReadString err=", err)
		}
		if line == "exit\r\n" {
			fmt.Println("客户端退出..")
			break
		}
		n, err := conn.Write([]byte(line))
		if err != nil {
			fmt.Println("conn.Write err=", err)
		}
		fmt.Printf("客户端发送了%d字节的数据\n", n)
	}
}
